//
//  YZAttDocInfoScrollView.m
//  kuaiyi
//
//  Created by Liu on 16/5/6.
//
//

#import "YZAttDocInfoScrollView.h"
#import "NSString+LiuStringSize.h"

@interface YZAttDocInfoScrollView ()<UIScrollViewDelegate>

/**
 *  接诊条件的label
 */
@property (nonatomic , strong)UILabel *AttDocConditionLabel;
/**
*  医生简介的label
*/
@property (nonatomic , strong)UILabel *AttDocInfoLabel;

@end

@implementation YZAttDocInfoScrollView


//先调
-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame ];
    [self addSubview: self.AttDocConditionLabel];
    [self addSubview: self.AttDocInfoLabel];
    self.backgroundColor = [UIColor whiteColor];
    self.delegate = self;
    //分页
    self.pagingEnabled = YES;
    //设置为水平滚动
    self.contentSize = CGSizeMake([UIScreen mainScreen].bounds.size.width*2, 0);

    return self;
}


#pragma mark - 代理方法


-(void)scrollViewDidScroll:(UIScrollView *)scrollView {
//        NSLog(@"1......=>%f",self.contentOffset.x);
        if (self.contentOffset.x > self.frame.size.width * 0.25 && self.contentOffset.x < self.frame.size.width * 0.5) {
            //187.5->375
            self.AttDocInfoBlock();
            self.contentoffsetNewX = self.contentOffset.x;
        }
}

#pragma mark - 懒加载
/**
 *  左边的label->接诊条件
 */
-(UILabel *)AttDocConditionLabel {
    if (_AttDocConditionLabel == nil) {
        _AttDocConditionLabel = [[UILabel alloc]init];
        _AttDocConditionLabel.text = @"我是接诊条件啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊";
        NSDictionary *att=@{NSFontAttributeName:[UIFont systemFontOfSize:18]};
        CGSize sizeNew = [self.AttDocConditionLabel.text sizeWithMaxSize:CGSizeMake(365, MAXFLOAT) andAtt:att];
        
        self.AttDocConditionLabel.numberOfLines = 0;
        
        _AttDocConditionLabel.frame = CGRectMake(10, 0, sizeNew.width, sizeNew.height);
        NSLog(@"%@",NSStringFromCGRect(self.AttDocConditionLabel.frame));
    }
    return _AttDocConditionLabel;
}

/**
 *  右边的label->医生简介
 */
-(UILabel *)AttDocInfoLabel {
    if (_AttDocInfoLabel == nil) {
        _AttDocInfoLabel = [[UILabel alloc]init];
        _AttDocInfoLabel.text = @"我是医生简介啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊";
        
        NSDictionary *att=@{NSFontAttributeName:[UIFont systemFontOfSize:18]};
        CGSize sizeNew = [self.AttDocInfoLabel.text sizeWithMaxSize:CGSizeMake(365, MAXFLOAT) andAtt:att];
        self.AttDocConditionLabel.numberOfLines = 0;
        
        self.AttDocInfoLabel.numberOfLines = 0;
        _AttDocInfoLabel.frame = CGRectMake(385, 0, sizeNew.width, sizeNew.height);
    }
    return _AttDocInfoLabel;
}



@end
